/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2010
 */

package com.osgix.authorize.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Id;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import com.osgix.common.orm.ibatis.BaseEntity;

public class PrivilegeInfo extends BaseEntity implements java.io.Serializable {
	private static final long serialVersionUID = 5454155825314635342L;

	//alias
	public static final String TABLE_ALIAS = "PrivilegeInfo";
	public static final String ALIAS_PRIVILEGE_ID = "privilegeId";
	public static final String ALIAS_PRIVILEGE_NAME = "privilegeName";
	public static final String ALIAS_PRIVILEGE_VALUE = "privilegeValue";
	public static final String ALIAS_ACCESS_TYPE = "accessType";
	public static final String ALIAS_ACCESS_URL = "accessUrl";

	//date formats

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
	@Id
	private java.lang.Long privilegeId;
	@NotBlank
	@Length(max = 128)
	private java.lang.String privilegeName;
	@Length(max = 128)
	private java.lang.String privilegeValue;
	@Length(max = 32)
	private java.lang.String accessType;
	@Length(max = 512)
	private java.lang.String accessUrl;

	//columns END

	public PrivilegeInfo() {
	}

	public PrivilegeInfo(java.lang.Long privilegeId) {
		this.privilegeId = privilegeId;
	}

	public void setPrivilegeId(java.lang.Long value) {
		this.privilegeId = value;
	}

	public java.lang.Long getPrivilegeId() {
		return this.privilegeId;
	}

	public void setPrivilegeName(java.lang.String value) {
		this.privilegeName = value;
	}

	public java.lang.String getPrivilegeName() {
		return this.privilegeName;
	}

	public void setPrivilegeValue(java.lang.String value) {
		this.privilegeValue = value;
	}

	public java.lang.String getPrivilegeValue() {
		return this.privilegeValue;
	}

	public void setAccessType(java.lang.String value) {
		this.accessType = value;
	}

	public java.lang.String getAccessType() {
		return this.accessType;
	}

	public void setAccessUrl(java.lang.String value) {
		this.accessUrl = value;
	}

	public java.lang.String getAccessUrl() {
		return this.accessUrl;
	}

	private Set rolePrivileges = new HashSet(0);

	public void setRolePrivileges(Set<RolePrivilege> rolePrivilege) {
		this.rolePrivileges = rolePrivilege;
	}

	public Set<RolePrivilege> getRolePrivileges() {
		return rolePrivileges;
	}

	private Set privilegeResources = new HashSet(0);

	public void setPrivilegeResources(Set<PrivilegeResource> privilegeResource) {
		this.privilegeResources = privilegeResource;
	}

	public Set<PrivilegeResource> getPrivilegeResources() {
		return privilegeResources;
	}

	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("PrivilegeId", getPrivilegeId())
				.append("PrivilegeName", getPrivilegeName()).append("PrivilegeValue", getPrivilegeValue())
				.append("AccessType", getAccessType()).append("AccessUrl", getAccessUrl()).toString();
	}

	public int hashCode() {
		return new HashCodeBuilder().append(getPrivilegeId()).toHashCode();
	}

	public boolean equals(Object obj) {
		if (obj instanceof PrivilegeInfo == false)
			return false;
		if (this == obj)
			return true;
		PrivilegeInfo other = (PrivilegeInfo) obj;
		return new EqualsBuilder().append(getPrivilegeId(), other.getPrivilegeId()).isEquals();
	}
}
